package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.LogingInfoDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.LogingInfo;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface LogingInfoMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    BasicColumn[] selectList = BasicColumn.columnList(infoId, loginName, ipaddr, loginLocation, browser, os, status, msg, loginTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<LogingInfo> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("LogingInfoResult")
    Optional<LogingInfo> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="LogingInfoResult", value = {
        @Result(column="info_id", property="infoId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="login_name", property="loginName", jdbcType=JdbcType.VARCHAR),
        @Result(column="ipaddr", property="ipaddr", jdbcType=JdbcType.VARCHAR),
        @Result(column="login_location", property="loginLocation", jdbcType=JdbcType.VARCHAR),
        @Result(column="browser", property="browser", jdbcType=JdbcType.VARCHAR),
        @Result(column="os", property="os", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.CHAR),
        @Result(column="msg", property="msg", jdbcType=JdbcType.VARCHAR),
        @Result(column="login_time", property="loginTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<LogingInfo> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, logingInfo, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, logingInfo, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int deleteByPrimaryKey(Long infoId_) {
        return delete(c -> 
            c.where(infoId, isEqualTo(infoId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int insert(LogingInfo record) {
        return MyBatis3Utils.insert(this::insert, record, logingInfo, c ->
            c.map(infoId).toProperty("infoId")
            .map(loginName).toProperty("loginName")
            .map(ipaddr).toProperty("ipaddr")
            .map(loginLocation).toProperty("loginLocation")
            .map(browser).toProperty("browser")
            .map(os).toProperty("os")
            .map(status).toProperty("status")
            .map(msg).toProperty("msg")
            .map(loginTime).toProperty("loginTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int insertSelective(LogingInfo record) {
        return MyBatis3Utils.insert(this::insert, record, logingInfo, c ->
            c.map(infoId).toPropertyWhenPresent("infoId", record::getInfoId)
            .map(loginName).toPropertyWhenPresent("loginName", record::getLoginName)
            .map(ipaddr).toPropertyWhenPresent("ipaddr", record::getIpaddr)
            .map(loginLocation).toPropertyWhenPresent("loginLocation", record::getLoginLocation)
            .map(browser).toPropertyWhenPresent("browser", record::getBrowser)
            .map(os).toPropertyWhenPresent("os", record::getOs)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(msg).toPropertyWhenPresent("msg", record::getMsg)
            .map(loginTime).toPropertyWhenPresent("loginTime", record::getLoginTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default Optional<LogingInfo> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, logingInfo, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default List<LogingInfo> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, logingInfo, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default List<LogingInfo> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, logingInfo, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default Optional<LogingInfo> selectByPrimaryKey(Long infoId_) {
        return selectOne(c ->
            c.where(infoId, isEqualTo(infoId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, logingInfo, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    static UpdateDSL<UpdateModel> updateAllColumns(LogingInfo record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(infoId).equalTo(record::getInfoId)
                .set(loginName).equalTo(record::getLoginName)
                .set(ipaddr).equalTo(record::getIpaddr)
                .set(loginLocation).equalTo(record::getLoginLocation)
                .set(browser).equalTo(record::getBrowser)
                .set(os).equalTo(record::getOs)
                .set(status).equalTo(record::getStatus)
                .set(msg).equalTo(record::getMsg)
                .set(loginTime).equalTo(record::getLoginTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(LogingInfo record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(infoId).equalToWhenPresent(record::getInfoId)
                .set(loginName).equalToWhenPresent(record::getLoginName)
                .set(ipaddr).equalToWhenPresent(record::getIpaddr)
                .set(loginLocation).equalToWhenPresent(record::getLoginLocation)
                .set(browser).equalToWhenPresent(record::getBrowser)
                .set(os).equalToWhenPresent(record::getOs)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(msg).equalToWhenPresent(record::getMsg)
                .set(loginTime).equalToWhenPresent(record::getLoginTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int updateByPrimaryKey(LogingInfo record) {
        return update(c ->
            c.set(loginName).equalTo(record::getLoginName)
            .set(ipaddr).equalTo(record::getIpaddr)
            .set(loginLocation).equalTo(record::getLoginLocation)
            .set(browser).equalTo(record::getBrowser)
            .set(os).equalTo(record::getOs)
            .set(status).equalTo(record::getStatus)
            .set(msg).equalTo(record::getMsg)
            .set(loginTime).equalTo(record::getLoginTime)
            .where(infoId, isEqualTo(record::getInfoId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.6+08:00", comments="Source Table: sys_logininfor")
    default int updateByPrimaryKeySelective(LogingInfo record) {
        return update(c ->
            c.set(loginName).equalToWhenPresent(record::getLoginName)
            .set(ipaddr).equalToWhenPresent(record::getIpaddr)
            .set(loginLocation).equalToWhenPresent(record::getLoginLocation)
            .set(browser).equalToWhenPresent(record::getBrowser)
            .set(os).equalToWhenPresent(record::getOs)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(msg).equalToWhenPresent(record::getMsg)
            .set(loginTime).equalToWhenPresent(record::getLoginTime)
            .where(infoId, isEqualTo(record::getInfoId))
        );
    }
}